﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes.actions {
    import flash.geom.*;
    import Classes.*;

    public class ActionBusinessOpen extends BaseResourceAction {

        protected var m_business:Business;

        public function ActionBusinessOpen(_arg1:NPC, _arg2:HarvestableResource){
            super(_arg1, _arg2);
            if (((_arg2) && ((_arg2 is Business)))){
                this.m_business = (_arg2 as Business);
            } else {
                this.m_business = null;
            };
        }
        override public function update(_arg1:Number):void{
            var _local2:Number;
            var _local3:String;
            if (m_actionStarted){
                if (((this.m_business) && (!(this.m_business.isOpen())))){
                    m_actionTime = (m_actionTime + _arg1);
                    _local2 = (m_actionTime / this.m_business.getOpenTime());
                    if (_local2 > 1){
                        if (Global.player.checkEnergy(-(this.m_business.harvestingDefinition.openEnergyCost))){
                            this.m_business.openBusiness();
                        } else {
                            this.m_business.displayStatus(ZLoc.t("Main", "NotEnoughEnergyRed"));
                        };
                        m_npc.getStateMachine().removeState(this);
                    } else {
                        if (this.m_business.showActionBar()){
                            _local3 = this.m_business.getOpeningText();
                            this.m_business.setActionBarOffset(0, (this.m_business.content.height >> 1));
                            this.m_business.setActionProgress(true, _local3, _local2, false);
                        };
                    };
                } else {
                    m_npc.getStateMachine().removeState(this);
                };
            };
        }
        override public function enter():void{
            super.enter();
            if (this.m_actionStarted){
                m_npc.hideFeedbackBubble();
            };
        }
        override public function reenter():void{
            super.reenter();
        }
        override public function exit():void{
            this.m_business.setActionProgress(false);
            this.m_business.setActionBarOffset(0, 0);
            super.exit();
        }
        override protected function getActionPosition():Point{
            return (null);
        }

    }
}//package Classes.actions 
